/**
 * 
 */
package org.swing.table.filter;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JTextField;
import javax.swing.table.TableModel;

import org.swing.table.imp.InlineFilter;
import org.swing.table.imp.InlineFilterListener;

/**
 * @author lqnhu
 *
 */
public abstract class AbstractInlineFilter implements InlineFilter {
	private final List<InlineFilterListener> listeners;

	public AbstractInlineFilter() {
		this.listeners = new ArrayList<InlineFilterListener>();
	}

	public void addInlineFilterListener(InlineFilterListener l) {
		this.listeners.add(l);
	}

	public void removeInlineFilterListener(InlineFilterListener l) {
		this.listeners.remove(l);
	}

	protected void fireFilter() {
		for (InlineFilterListener l : this.listeners) {
			l.fireFilter();
		}
	}

	protected void link(JTextField source, JTextField target) {
		target.setDocument(source.getDocument());
	}

	public void setTableModel(int column, TableModel model) {
		// empty by default, see the combobox filter
	}
}
